package car.aistar.config;

import car.aistar.interceptor.UserLoginInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @ClassName InterceptorConfig
 * @Description TODO
 * @Author laoxu
 * @Date 2020/10/22 21:49
 * Version 1.0
 **/

@Configuration
public class InterceptorConfig implements WebMvcConfigurer{
    @Bean
    UserLoginInterceptor userLoginInterceptor() {
        return new UserLoginInterceptor();
    }



    @Override
    public void addInterceptors(InterceptorRegistry registry) {


        // 拦截用户请求
        registry.addInterceptor(userLoginInterceptor())
                // 斜杠 / 一定要加上
                .addPathPatterns("/Personal/*", "/userDetail/*","/seller/*")// /Personal
                // 不拦截的登录，只要是pub都不进行拦截，用户登录注册不拦截
                .excludePathPatterns(
                        "/IndexJsp/toIndex", "/cardetail/infor", "/logAndRegist/toLog","/DealXu/view","/NavJsp/toBuyCar");
    }
}
